package ctvc;

import java.util.Arrays;

public class Main1 {
    public static void main(String[] args) {
        String str[]={"ne","going","god"};
        String ans=returnSampleChar(str);
        System.out.println(ans);
    }

    public static String returnSampleChar(String[] strings){
        int len=strings.length;
        int l[]=new int[len];
        int minLen=0;
        for(int i=0;i<len;++i){
            l[i]=strings[i].length();
        }
        Arrays.sort(l);
        minLen=l[0];
        StringBuffer sbf=new StringBuffer("");
        for(int i=0;i<minLen;++i){//最短的单词的长度
            char a=strings[0].charAt(i);
            for(int j=1;j<len;++j){
                if(a!=strings[j].charAt(i)){
                    //程序结束
                    return sbf.toString();
                }
            }
            sbf.append(a);
        }
        return sbf.toString();
    }
}
